//
// C++ Implementation: applicationdesktopscanner
//
// Description:
//
//
// Author: Ernesto Barragan <ernestus *at* gmail.com>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include <QDir>
#include <QFileInfo>
#include "applicationdesktopscanner.h"


ApplicationDesktopScanner::ApplicationDesktopScanner()
{
}


ApplicationDesktopScanner::~ApplicationDesktopScanner()
{
}


/*!
    \fn ApplicationDesktopScanner::scanDirectory( QString dirPath )
    This function does not recurse into directories!
 */
ApplicationInfo::List ApplicationDesktopScanner::scanDirectory( QString dirPath )
{
    QDir d( dirPath ) ;
    d.setFilter( QDir::Files ) ;
    //d.setSorting( QDir::Name ) ; ///@todo really necessary?
    //const QFileInfoList list(d.entryInfoList()) ;
    QFileInfoList::const_iterator it ;
    ApplicationInfo::List appList ;
    for (it = d.entryInfoList().constBegin(); it != d.entryInfoList().constEnd(); ++it)
    {
        ApplicationInfo appinfo( (*it).fileName() ) ;
        if( true == appinfo.isValid() )
        {
            appList += appinfo ;
        }
        ++it;
    }

    return appList ;
}
